home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
32-bit_x86
/
Russian
/
cpsimage.cab
/
data
/
xps
/
xmetWriteImg.proc
< prev
next >
Wrap
Text File
|
2009-03-16
|
3KB
|
101 lines
/* @WriteLayer
// DESCRIPTION
Write the layer for the image provided. Both the directory and filename
are given. If the directory or filename, "fname", are not given
nothing is done and the call returns.
*/
private
PROCEDURE
WriteLayer (XIPIMAGE img,
STRING dir,
STRING fname,
INTEGER pgNum,
INTEGER layerNum,
INTEGER isTIFF)
{
INTEGER ltype = img.getMember (num:layerNum, member:"layerType");
INTEGER comp = img.getMember (num:layerNum, member:"compression");
STRING ext = "." + mapExt (img: img, layer: layerNum, isTIFF: isTIFF);
// SetStatus (op: "debug");
if ( ! dir || ! fname )
return;
if ( ltype == XIP_JBIG2Dict || ltype == XIP_Text || ltype == XIP_Thumbnail)
return;
// Write files; waiting until we get ability to write compressed directly
// Till then we have to uncompress and write, ugly!
XIPIMAGE imgL = img.getLayer (num: layerNum);
if ( ltype == XIP_Contone || comp == XIP_JPEG_COMP) {
// This handles PDF cascaded compression of Jpeg followed with deflate
if (comp != XIP_JPEG_COMP)
imgL = imgL.unCompress();
imgL.writejpgop (filename: dir +"/Images/pg"+ pgNum +fname +layerNum +ext);
}
else if ( ltype == XIP_ColorMask || ltype == XIP_Binary || ltype == XIP_ContoneMask) {
STRING outFile = dir +"/Images/pg"+ pgNum + fname + layerNum + ext;
if ( ltype == XIP_ColorMask || ltype == XIP_ContoneMask) {
imgL = imgL.unCompress ();
if ( imgL.getMember (member: "photometry") == XIP_K_COLOR )
imgL = imgL.invert();
imgL = imgL.modheader (modify: ("Photometry:transparency:0", // png tag
"Encoding:interleave:pixel",
"Photometry:name:grayLinear") );
}
else
imgL = imgL.unCompress();
/* For now set the resolution to 0 in order to prevent XPS viewer using it */
if ( ext == ".tif" || ext == ".TIF" )
imgL.writetifop (filename: outFile, ccitt: 4, noicc:TRUE);
else if ( ext == ".png" || ext == ".PNG" )
imgL.writepng (filename: outFile);
else {
print "WriteLayer: Error, not configured for writing " + ext + " files";
return;
}
}
Execute ();
// SetStatus (op: "debug");
}
/* @GetFile
// DESCRIPTION
Read an IMS file into XIPIMAGE object and returns it to the caller.
Assumes the IMS file has an extension of ims on the file name. If not
it does a readimage and tries to return that as an XIPIMAGE.
*/
private
PROCEDURE GetFile (STRING name)
RETURNS (XIPIMAGE img)
{
// Object used to manage error infformatormation in a try-catch call
STATUS status;
STRING imsName;
// Try to read the input IMS file
try {
if ( name.ext() == "ims" || name.ext() == "IMS")
img = ReadIMS (filename: name).exec();
else
img = readimage (filename: name).exec();
} catch {
print "Error: " + status.message;
}
}